<?php
namespace Wap\Controller;
use Think\Controller;
class ApiController extends BaseController {
    	
    public function index(){
		
		$this->display();
    }
	
	
	 public function get_shop(){
	 	if($_POST){
	 		$m=M('cf_store');
			$lat=$_POST['latitude'];
			$lon=$_POST['longitude'];
			$sql='select * from cf_store where diPointY > '.$lat.'-1 and diPointY < '.$lat.'+1 and diPointX > '.$lon.'-1 and diPointX < '.$lon.'+1 order by ACOS(SIN(('.$lat.' * 3.1415) / 180 ) *SIN((diPointY * 3.1415) / 180 ) +COS(('.$lat.' * 3.1415) / 180 ) * COS((diPointY * 3.1415) / 180 ) *COS(('.$lon.'* 3.1415) / 180 - (diPointX * 3.1415) / 180 ) ) * 6380 asc limit 300';
			$data=$m->query($sql);
			if($data){
				foreach ($data as $k => $v){
					$dat[$k]['name']=$v['name'];
					$dat[$k]['m']=GetDistance($lon, $lat, $v['dipointx'],$v['dipointy']);		//离我多少米距离
				}
				unset($data);
				$data['status'] = 1;
				$data['msg'] = 'ok';
				$data['data'] = $dat;
			}else{
				$data['status'] = 0;
				$data['msg'] = '该附近没有干洗店！';
			}
			$this->ajaxReturn($data);
	 	}
    }
	
}